fix indexing issues